package com.zhsj.OkeHomeConsumption.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.zhsj.OkeHomeConsumption.R;
import com.zhsj.OkeHomeConsumption.empty.WalletBean;

import java.util.List;

/**
 * Created by zwj on 2018/3/13.
 */

public class InviteItemAdapter extends BaseAdapter {

    private Context context;
    private List<WalletBean> list;
    private LayoutInflater mLayoutInflater;

    public InviteItemAdapter(Context context, List<WalletBean> walletList) {
        this.context = context;
        this.list = walletList;
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = mLayoutInflater.inflate(R.layout.item_money_invite_item, null);
            viewHolder.name_text = (TextView) convertView.findViewById(R.id.name_text);
            viewHolder.money_text = (TextView) convertView.findViewById(R.id.money_text);
            viewHolder.des_text = (TextView) convertView.findViewById(R.id.des_text);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final WalletBean item = list.get(position);

        if (item != null) {

            if (item.getPartnership() == 5){
                viewHolder.name_text.setText("城市运营商合伙人");
            }else if (item.getPartnership() == 0 || item.getPartnership() == 20 || item.getPartnership() == 26){
                viewHolder.name_text.setText("事业合伙人");
            }else if (item.getPartnership() == 1 || item.getPartnership() == 21 || item.getPartnership() == 35){
                viewHolder.name_text.setText("设计师合伙人");
            }else if (item.getPartnership() == 2){
                viewHolder.name_text.setText("家装管家");
            }else if (item.getPartnership() == 3){
                viewHolder.name_text.setText("工长合伙人");
            }else if (item.getPartnership() == 15){
                viewHolder.name_text.setText("客户");
            }else {
                viewHolder.name_text.setText("合伙人");
            }
            viewHolder.money_text.setText(item.getAmount() + "元");
            viewHolder.des_text.setText(item.getDes());
        }
        return convertView;
    }


    class ViewHolder {
        private TextView name_text;
        private TextView money_text;
        private TextView des_text;

    }
}
